﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using diploma.test.core;
using diploma.core.data;


namespace diploma.test
{
    sealed internal class TestManager
    {
        private TestManager() { }
        private const int MAX_QUESTIONS_COUNT = 15;

        static TestManager instance = null;
        internal static TestManager Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new TestManager();
                }
                return instance;
            }
        }

        List<Question> test;
        internal Dictionary<DataObjectTypes, DataList<diploma.core.data.IDataObject>> Collection
        {
            get
            {
                return collection;
            }
        }

        Dictionary<DataObjectTypes, DataList<diploma.core.data.IDataObject>> collection;
        internal Question[] MakeTest(Dictionary<DataObjectTypes, DataList<diploma.core.data.IDataObject>> _collection)
        {
            collection = _collection;
            Random rand = new Random();
            Array str = Enum.GetValues(typeof(TestStrategy));
            test = new List<Question>();
            for (int i = 0; i < MAX_QUESTIONS_COUNT; i++)
            {
                Question tmp = TestItem.GetItem(test);
                if (tmp != null)
                {
                    test.Add(tmp);
                }
            }
            return test.ToArray();
        }
    }
}
